package model.factory;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import model.classesDAO.ClienteDAO;
import model.classesDAO.EnderecoDAO;
import model.classesDAO.IngredienteDAO;
import model.classesDAO.NoticiaDAO;
import model.classesDAO.ReceitaDAO;

public abstract class Fabrica {
	
	private static EntityManager em;
	private static final EntityManagerFactory emf;
	
	static{
		
		emf = Persistence.createEntityManagerFactory("Administer");
		
		if (em == null){
			
			em = emf.createEntityManager();
		}
		
	}
	
	public static IngredienteDAO getIngredienteDAO(){
		IngredienteDAO ingredienteDAO = new IngredienteDAO();
		ingredienteDAO.setEntityManager(em);	
		return ingredienteDAO;		
	}
	
	public static NoticiaDAO getNoticiaDAO(){
		NoticiaDAO noticiaDAO = new NoticiaDAO();
		noticiaDAO.setEntityManager(em);	
		return noticiaDAO;	
	}
	
	public static ReceitaDAO getReceitaDAO(){
		ReceitaDAO receitaDAO = new ReceitaDAO();
		receitaDAO.setEntityManager(em);	
		return receitaDAO;	
	}
	
	public static ClienteDAO getClienteDAO(){
		ClienteDAO clienteDAO = new ClienteDAO();
		clienteDAO.setEntityManager(em);	
		return clienteDAO;		
	}
	
	public static EnderecoDAO getEnderecoDAO(){
		EnderecoDAO enderecoDAO = new EnderecoDAO();
		enderecoDAO.setEntityManager(em);	
		return enderecoDAO;		
	}
	
}
